<%
function getStatusTime(status, item) {
    if (status == 1) {
        return item.require_time;
    }
    if (status == 2) {
        return item.cancel_require_time;
    }
    if (status == 3) {
        return item.require_confirm_time;
    }
    if (status == 4) {
        return item.develop_time;
    }
    if (status == 5) {
        return item.submit_test_time;
    }
    if (status == 6) {
        return item.wait_online_time;
    }
    if (status == 7) {
        return item.online_time;
    }
    if (status == 8) {
        return item.mtime;
    }
}
_.each(list, function(item, key){
    var peopleAmount = 1;
    if (item.develop_members) {
        var peopleList = item.develop_members.split(',');
        if (!_.contains(peopleList, item.developer_id)) {
            peopleList.push(item.developer);
        }
        peopleAmount = peopleList.length;
    }

    var date_diff = '';
    if (item.develop_time != '0000-00-00 00:00:00') {
        var a = new Date(item.wish_time);
        var b = new Date(item.develop_time);
        var holidayLength = 0;
        var temp = b;
        while ((a.getTime() - temp.getTime()) > 86400000) {
            temp = new Date(temp.getTime() + 86400000);
            if (temp.getDay() == 6 || temp.getDay() == 0) {
                holidayLength += 86400000;
            }
        }
        date_diff = Math.abs(a.getTime() - b.getTime() - holidayLength) / 86400000 * peopleAmount;
        date_diff = date_diff.toFixed(0);
    }
%>
<tr class="data-list" style="color:<%= item.critical == 1 ? 'green' : (item.critical == 2 ? 'blue' : 'red') %>;">
    <td><span class="issue_id"><%= item.id %></span>&nbsp;&nbsp;&nbsp;&nbsp;<%= date_diff >= 4 ? '<a href="###" class="btn mini green editBtn">使命必达</a>' : '' %></td>
    <td><%= item.project_name %></td>
    <td><%= item.name %></td>
    <td><%= item.developer_nickname ? item.developer_nickname : item.developer %></td>
    <td><%= item.status %></td>
    <td><%= getStatusTime(item.status_id, item) %></td>
    <td><%= item.wish_time %></td>
    <td><%= date_diff %></td>
    <td><%= item.branch %></a></td>
    <td><a href="###" class="btn mini purple editBtn"><i class="icon-edit"></i> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="###" class="btn mini blue deleteBtn"><i class="icon-trash"></i> 删除</a></td>
</tr>
<%
});
%>